define(['jquery','validation'] , function(){
	var extraHandler = {
		init 	: 	function(){
			var defRule = {
				onfocusout 	: 	function( element ){
					$(element).valid() ;
				},
				errorPlacement: function( error , element ){
					$(element).parent('.form-group').removeClass('has-success').addClass('has-error') ;
					//$(element).parents('form').find('[data-for='+$(element).attr('name')+']').append( error ) ;
					$(element).parent('.form-group').attr('title' , error.text() ) ;
				},
				success: function( success , element ){
					$(element).parent('.form-group').removeClass('has-error').addClass('has-success') ;
					//$(element).parents('form').find('[data-for='+$(element).attr('name')+']').empty() ;
					$(element).parent('.form-group').attr('title' , '' ) ;
				}
			}
			$.fn._validate = $.fn.validate ;
			$.fn.extend({
				validate 	: 	function( rules ){
					$.extend( defRule , rules ) ;
					return $(this)._validate( defRule ) ;
				}
			});
			return this.addExpress().addEval() ;
		},
		addExpress 	: 	function(){
			$.validator.addMethod('express' , function( data , e , value ){
				var regexp = new RegExp( value );
				return this.optional( e ) || regexp.test( data ) ;
			},'格式不正确');
			return this ;
		},
		addEval 	: 	function(){
			$.validator.addMethod('eval' , function( data , e , value ){
				return this.optional( e ) || eval('(' + value +')')( data , e ) ;
			} , '参数校验不通过');
			return this ;
		}
	}.init() ;
});